﻿@{
	Layout = null;
}

<!DOCTYPE html>

<html>
<head>
	<meta name="viewport" content="width=device-width" />
	<title>组合条件搜索+分页</title>
	<style type="text/css">
		div, table, tr, td {
		margin: 0px;
		padding: 0px;
		}

		.myTable {
		width: 800px;
		margin: 20px auto;
		border-collapse: collapse;
		}

		.myTable td, .myTable th {
		height: 30px;
		line-heigh: 30px;
		padding: 6px;
		}
	</style>
</head>
<body>
	<h1>查询员工信息</h1>
	<form action="SearchForm" style="text-align: center;">
		所属部门：
		<select name="ddlDept" id="ddlDept">
			<option value="">--请选择--</option>
			@foreach (var item in ViewBag.listDept)
			{
				int deptId = 0;
				if (!string.IsNullOrEmpty(Context.Request.Query["ddlDept"]))
				{
					deptId = int.Parse(Context.Request.Query["ddlDept"].ToString());
				}
				//option前加叹号取消语法检查
				<!option value="@item.DeptId" @(item.DeptId==deptId?"selected":"")>@item.DeptName</!option>
			}
		</select>
		员工姓名：
		<input type="text" name="txtRealName" id="txtRealNname" value="@Context.Request.Query["txtRealName"]" />
		<input type="submit" value="搜 索" />
	</form>
	<a href="AddForm" target="_blank">添加员工</a>
	<table class="myTable" border="1">
		<tr>
			<th>员工编号：</th>
			<th>部门名称：</th>
			<th>员工姓名：</th>
			<th>员工电话：</th>
			<th>所在地区：</th>
			<th>员工工资：</th>

		</tr>
		@foreach (var item in ViewBag.listView)
		{


			<tr>
				<td>@item.EmpId</td>
				<td>@item.DeptName</td>
				<td>@item.EmpName</td>
				<td>@item.EmpPhone</td>
				<td>@item.EmpArea</td>
				<td>@item.EmpSalary</td>

			</tr>
		}
	</table>
	
	@* 通过上一页、下一页跳转时，限制条件不丢失 *@
	@{
		string urlParama = "ddlDept=" + Context.Request.Query["ddlDept"] +
		"&txtRealName=" + Context.Request.Query["txtRealNname"];
	}
	<form style="text-align: center;">
		<div style="height:30px;line-height:30px">
		<a href="SearchForm?page=1&@urlParama">首页</a>
			<a href="SearchForm?page=@(ViewBag.pageIndex-1)&@urlParama">上一页</a>
			<a href="SearchForm?page=@(ViewBag.pageIndex+1)&@urlParama">下一页</a>
			<a href="SearchForm?page=@ViewBag.pageCount&@urlParama">末页</a>
		转到：
		<input type="text" name="page" id="page" value="@ViewBag.pageIndex" style="width;"/>
			
		@* 下面两个隐藏域作用是通过go跳转页面时，选择的条件不丢失。 *@
		<input type="hidden" name="ddlDept" id="ddlDept" value="@Context.Request.Query["ddlDept"]" />
			<input type="hidden" name="txtRealNname" id="txtRealNname" value="@Context.Request.Query["ddlDept"]" />
		<input type="submit" value="go"/>
		当前第<span style="color:red">@ViewBag.pageIndex</span>页
			共<span style="color:red">@ViewBag.pageCount</span>页
		</div>
	</form>
</body>
</html>
